<%@page pageEncoding="UTF-8" %>
<%@page import="domain.MultiPart"%>
<%@page import="getools4me.BlogManager"%>
<%@page import="domain.DownloadableFile"%>
<%@page import="getools4me.UserManager"%>
<%@page import="com.google.appengine.api.users.User"%>
<%@page import="com.google.appengine.api.users.UserService"%>
<%@page import="com.google.appengine.api.users.UserServiceFactory"%>
<%
	UserService us = UserServiceFactory.getUserService();
	User user = us.getCurrentUser();
	String thisUrl = request.getRequestURI();
	String loginURL = us.createLoginURL(thisUrl);
	String logoutURL = us.createLogoutURL(thisUrl);
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

div.import{
	width: 60%;
	margin-left: 100px;
	border-top: 1px solid;
}





</style>

<title>Export</title>
</head>
<body>




<%if(user==null){ %> 
	<div class="center">
		<h1><a href="<%=loginURL%>">Please Login ...</a></h1>
	</div>
<%}else if(!user.getEmail().equals("jpgtama@gmail.com")) { %>
	<div class="center">
		<h1>Welcome, Mr. <%=user.getNickname() %> !</h1>
		<i>Sorry, you are not admin.(<a href="<%=logoutURL%>">Logout</a>)    </i>
	</div>
<%}else{ %>


<%
	MultiPart mp = new MultiPart(request.getInputStream());
%>

<div class="import">
	<%if(mp.getSizeOfPart()==0){ %>
		<p>Don't close window and upload data file again!</p>	
	<%}else{ %>
		<textarea rows="30" cols="50"><%//BlogManager.importData(mp)%>
		<%=mp.manifest() %>
		</textarea>
	<%} %>
</div>
<%} %>

<div class="footer">

	<iframe class="footer" src="/footer.html" frameborder="0" width="100%"></iframe>
	
</div>


</body>
</html>